<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create ('goods', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ('id');//uuid主键
            $table->uuid ('shop_id');//商店id
            $table->string ('goods_time', 100);//商品标题
            $table->string ('goods_desc');//商品描述
            $table->text ('goods_content');//商品内容
            $table->unsignedDecimal ('goods_price', 11, 2);//商品价格
            $table->unsignedDecimal ('market_price', 11, 2);//市场价格
            $table->bigInteger ('comment_number');//评论数
            $table->bigInteger ('sale_number');//销量
            $table->bigInteger ('goods_status');//商品状态
            $table->timestamps ();
            $table->foreign ('shop_id')->references ('id')->on ('shops')->onDelete ('cascade');//商店外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('goods');
        //
    }
}
